﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ClientAppViaWebService.BaseLogicServiceRef;

namespace ClientAppViaWebService.Forms
{
    public partial class SymbolismEditForm : EventEditForm
    {
        private BaseLogicServiceRef.BaseLogicService baseLogicService; 
        #region Properties

        public String Type
        {
            get
            {
                return txtType.Text;               
            }
            set { txtType.Text = value; }
        }
        public String Belonging
        {
            get
            {
                return txtBelonging.Text;                
            }
            set { txtBelonging.Text = value; }
        }
        public String FullName
        {
            get
            {
                return txtFullName.Text;
            }
            set { txtFullName.Text = value; }
        }
        public String WhoRatified
        {
            get
            {
                return txtWhoRatified.Text;
            }
            set { txtWhoRatified.Text = value; }
        }
        public DateTime DateOfCreate
        {
            get
            {
                return dtpDateOfCreate.Value;                
            }
            set { dtpDateOfCreate.Value = value; }
        }
       
        public SymbolismEditForm()
        {
            InitializeComponent();
        }
#endregion
       
        protected override void SetFormProperties(Object _object)
        {
            TObject o = (_object as TObject);
            ID = o.ID;
            EXT_ID = o.EXT_ID;
            ParentId = o.PARENT_ID;
            Class = o.CLASS_ID;
            ObjName = o.NAME;
        }

        protected override Object RetrieveFormProperties()
        {
            TObject obj = new TObject();
            obj.ID = ID;
            obj.EXT_ID = EXT_ID;
            obj.PARENT_ID = ParentId;
            obj.CLASS_ID = Class;
            obj.NAME = ObjName;
            obj.DataBaseName = DataBaseName;

            return obj;
        }

        protected override void LoadEditFormData(int parentNodeID)
        {
            TObject p = baseLogicService.SelectTObject_By_DataBase_And_Id(DataBaseName, parentNodeID);
            SetFormProperties(p);
        }

        protected override void UpdateEntity()
        {
            TObject obj = RetrieveFormProperties() as TObject;
            baseLogicService.UpdateTobject(obj);
        }

        protected override void InsertEntity()
        {
            TObject obj = RetrieveFormProperties() as TObject;
            baseLogicService.InsertTobject(obj);
        }



    }
}
